package com.agricultural.environment;

import java.util.Random;

public class HumiditySensor implements Sensor {
    private Random random = new Random();
    private double offset = 0;

    @Override
    public double readValue() {
        // 模拟湿度读数 (40-90%)
        return 40 + random.nextDouble() * 50 + offset;
    }

    @Override
    public void calibrate() {
        // 模拟校准过程
        offset = (random.nextDouble() - 0.5) * 5; // 随机偏移 (-2.5 到 2.5)
        System.out.println("湿度传感器校准完成，偏移量: " + offset);
    }
}    